home *** CD-ROM | disk | FTP | other *** search
- //---------------------------------------------------------------------------
- #include <vcl\vcl.h>
- #include <checks.h>
- #pragma hdrstop
- #include "DbgMain.h"
- //---------------------------------------------------------------------------
- #pragma resource "*.dfm"
- TMainForm *MainForm;
- //---------------------------------------------------------------------------
- __fastcall TMainForm::TMainForm(TComponent* Owner)
- : TForm(Owner)
- {
- OutputDebugString("Log file created.");
- OutputDebugString("Constructor executed.");
- }
- //---------------------------------------------------------------------------
- void __fastcall TMainForm::WatchBtnClick(TObject *Sender)
- {
- OutputDebugString("WatchBtnClick() executed.");
- //
- // Add watches to the Watch List for the s, x, and y
- // variables. Watch the variables change as you step
- // through the code.
- //
- String s;
- int x = Width;
- s = String(x);
- int y = Height;
- x *= y;
- s = String(x);
- x /= y;
- // SET A BREAKPOINT ON THE FOLLOWING LINE
- s = "s = " + String(x);
- OutputDebugString(s.c_str());
- //
- // The following function beeps the speaker. You
- // can either Step Over the function (F8) or you
- // can OutputDebugString Into the function (F7). Try it both
- // ways to see the difference
- //
- BeepFunction();
- //
- // Click the Run button again now to return to
- // the Debug Test program.
- //
- Width = x;
- Height = y;
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::CrashBtnClick(TObject *Sender)
- {
- OutputDebugString("CrashBtnClick() executed.");
- //
- // The second line below should be highligted
- // showing you that the program failed on that
- // line. The reason the program failed there is
- // because the 'list' pointer was never intialzied.
- // This is a controlled crash because since we have
- // set the 'list' variable to 0 we know that it
- // does not contain some random data. You will have
- // to choose Run | Program Reset from the main menu
- // to terminate the program.
- //
- TStringList* list = 0;
- list->Add("test");
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::BadCrashBtnClick(TObject *Sender)
- {
- OutputDebugString("BadCrashBtnClick() executed.");
- //
- // You will probably never get here while debugging.
- // The program crashes because the 'list' pointer
- // is never initialized and contains some random data.
- // When we attempt to call a function the program
- // jumps off to who-knows-where and tromps on some
- // memory somewhere.
- //
- TStringList* list;
- list->Add("test");
- }
- //---------------------------------------------------------------------
- void TMainForm::BeepFunction()
- {
- OutputDebugString("BeepFunction() executed.");
- //
- // If you are here it is because you have used
- // OutputDebugString Into (F7} from the WatchButtonClick()
- // function.
- //
- MessageBeep(-1);
- }
- void __fastcall TMainForm::InspectBtnClick(TObject *Sender)
- {
- OutputDebugString("InspectBtnClick() executed.");
- TStringList* list = new TStringList();
- list->Add("This is a test");
- list->Add("Josh, Jenna, James");
- // SET A BREAKPOINT ON THE FOLLOWING LINE
- list->Add("Marshall, Mallory, Mason");
- //
- // Inspect an object. Click on the word 'list' above
- // and choose Inspect from the speed menu or press
- // Alt-F5. The Debug Inspector will be displayed.
- //
- // After you are done inspecting the 'list' object
- // choose Run | Inspect from the main menu. When the
- // Inspect dialog box comes up type 'this' in the
- // Expression field and click OK. You will then be
- // able to inspect the main form class.
- //
- delete list;
- // Click the Run button again to return control
- // back to the Debug Test program.
- }
- //---------------------------------------------------------------------
- void __fastcall TMainForm::FormClose(TObject *Sender, TCloseAction &Action)
- {
- OutputDebugString("FormClose() executed.");
- }
- //---------------------------------------------------------------------------
-